package edu.sjtu.context.persist;

import java.io.FileNotFoundException;
import java.net.URL;

import edu.sjtu.context.core.OntologyExistException;
import edu.sjtu.context.core.OntologyNotFoundException;

import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;

public interface PersistManager {
	/**
	 * to add a ontology to the ontology library.
	 * @param ontName
	 * 		the name of the ontology to be saved to the ontology library
	 * @param url
	 * 		the url where to get the ontology.
	 * @throws OntologyExistException
	 * 		if the name of the being added ontology is already exist, throw a exceition
	 * @author Roger
	 */
	public void addOntology(String ontName, String url)
			throws OntologyExistException, OntologyNotFoundException, Exception;
	
	/**
	 * to get a ontology from the ontology library.
	 * @param name
	 * 		the name of the ontology. If the notology is exist, this method will return the ontology, or 
	 * 		it will return null.
	 * @return
	 * 		return value.
	 */
	public JenaOWLModel getOntology(String name);
	
	/**
	 * to see if a ontology with the given name is in the ontology library or not.
	 * @param ontName
	 * 		name of the ontology
	 * @return
	 * 		return true if the ontology with the given name is already in the ontology library, or false.
	 */
	public boolean isOntExist(String ontName);
	
	/**
	 * set ontology library path. Generally, user should not use this method.
	 * @param path
	 * 		ontology library path
	 * @author Roger
	 */
	public void setOntLibPath(String path);
	
	/**
	 * get the ontology library path
	 * @return
	 * 		ontology library path
	 * @author Roger
	 */
	public String getOntLibPath();
	
	/**
	 * remove ontology with the given name from the ontology library.
	 * @param ontName
	 * 		name of the ontology to be removed.
	 * @return
	 * 		if successful return 0, or return -1.
	 * @throws OntologyNotFoundException
	 * 		if the ontology with the given name is not exist, throw an Exception.
	 */
	public void removeOntology(String ontName)
		throws OntologyNotFoundException ;
	
	/**
	 * get all ontologies from the ontology library
	 * 
	 * @return
	 * 		return an array which contain names of all ontologies
	 */
	public String[] getOntologies();
	
	/**
	 * update exsit ontology represent by OWLModel.
	 * @param model
	 * 		the ontology to be updated.
	 * @param ontName
	 * 		the name of the ontology to be update.
	 */
	public void updateOntology(JenaOWLModel model, String ontName);
}
